

var body;
var tooltip;

function show_tooltip(event) {

	var what = Event.element(event).getAttribute("alt");

	what.replace(/'/g, "\"");

	tooltip.innerHTML  = what;
	tooltip.style.top  = Event.pointerY(event)+8 + "px";
	tooltip.style.left = Event.pointerX(event)+8 + "px";
	tooltip.style.visibility = "visible";

	Event.observe(Event.element(event), "mouseout", hide_tooltip);
	Event.observe(Event.element(event), "mousemove", move_tooltip);
}

function move_tooltip(event) {
	tooltip.style.top  = Event.pointerY(event)+8 + "px";
	tooltip.style.left = Event.pointerX(event)+8 + "px";
}

function hide_tooltip(event) {
	tooltip.style.visibility = "hidden";
	Event.stopObserving(Event.element(event), "mouseout", hide_tooltip);
	Event.stopObserving(Event.element(event), "mousemove", move_tooltip);
}

function get_elements_by_attribute(attr) {
	var tags=document.getElementsByTagName('*');
	var arr = new Array();
	for(var i=0;i<tags.length;i++){
		if (tags[i].getAttributeNode(attr)) {
			arr[arr.length] = tags[i];
		}
	}
	return arr;
}


function parse_tooltips() {

	var tt = get_elements_by_attribute("alt");

	for (var i=0; i<tt.length; i++) {
		if (tt[i].getAttribute("alt") != "") {
			Event.observe(tt[i], "mouseover", show_tooltip);
			tt[i].style.cursor = "pointer";
		}
	}

}


function init() {

	body = document.getElementsByTagName("body").item(0);

	tooltip = document.createElement("div");
	tooltip.className = "tooltip";
	body.appendChild(tooltip);

	parse_tooltips();
}


Event.observe(window, "load", init);